from datetime import datetime
import time
import warnings


def important(fn):
    print("the %s() method implement is required!" % fn.__name__)

    def wrapper(*args):
        return fn(*args)

    return wrapper


def deprecated(fn):
    warnings.warn("此方法已废弃，不推荐使用", DeprecationWarning)

    def wrapper(*args):
        return fn(*args)

    return wrapper


def cost_time(fn):
    def wrapper(*args):
        start_time = time.time()
        result = fn(*args)
        end_time = time.time()
        cost = end_time - start_time

        if cost >= 0.1:
            print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + " " + fn.__name__ + " cost:" + str(cost))
        return result

    return wrapper
